#ifndef QCCCORE_H
#define QCCCORE_H

#include <QtCore>
#include "data.h"
#include "common.h"

class QccApplication;

class QccSettings;

class IQccServiceAccess;
class QccServiceAccessFake;

class QccCache;

typedef Singleton<QccApplication> Application;
typedef Singleton<QccSettings> Settings;
typedef IocSingleton<IQccServiceAccess, QccServiceAccessFake> ServiceAccess;
typedef Singleton<QccCache> Cache;

class QccApplication
{
public:
    /** Название программы **/
    Property<QString> Name;
    /** Текущий пользователь **/
    Property<User>    CurrentUser;
    /** Св-ва бизи индикатора **/
    Property<bool>    IsBusy;
    Property<QString> BusyMessage;
};

class QccSettings
{

};

class IQccServiceAccess
{
public:
    virtual QString tryLogin(QString Login, QString Hash) = 0;
    virtual QHash<QString, QString> getUser(QString Session) = 0;
};

class QccServiceAccessFake : IQccServiceAccess
{
public:
    QString tryLogin(QString Login, QString Hash)
    {
        if (Login == "test" && Hash.isEmpty())
        {
            return "1234567890";
        }
        return QString();
    }

    QHash<QString, QString> getUser(QString Session)
    {
        QHash<QString,QString> result;
        if (Session.isNull() || Session.isEmpty())
        {
            return result;
        }

        result.insert("Name", "Eugeniy");
        result.insert("Email", "test@test.ru");
        result.insert("Id", "1");
        return result;
    }
};

class QccCache
{
public:
    QHash<qint32, Clan> Clans;
    QHash<qint32, Game> Games;

};

#endif // QCCCORE_H
